﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestConsoleApp
{
    public record Order(int Items, decimal Cost);

    public class TestPatternMatching
    {
        public static void Test()
        {
            var order = new Order(20, 1000);


            Console.WriteLine(CalculateDiscount(order));
        }

        static string WaterState(int tempInFahrenheit)
        {
            return tempInFahrenheit switch
            {
                (> 32) and (< 212) => "liquid",
                < 32 => "solid",
                > 212 => "gas",
                32 => "solid/liquid transition",
                212 => "liquid / gas transition",
            };
        }


        static decimal CalculateDiscount(Order order) =>
            order switch
            {
                (Items: > 10, Cost: > 1000.00m) => 0.10m,
                (Items: > 5, Cost: > 500.00m) => 0.05m,
                Order { Cost: > 250.00m } => 0.02m,
                null => throw new ArgumentNullException(nameof(order), "Can't calculate discount on null order"),
                var someObject => 0m,
            };

    }


}
